﻿using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using tieba_gzh.Models;
using tieba_gzh.Models.DB;

namespace tieba_gzh.DAL
{
    public class DAL_tiezi
    {
        public List<tiezi> gettiezi()
        {
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString1"]);
            var list = mySqlConnection.Query<tiezi>("select  *  from tiezi").ToList();
            return list;
        }
        public List<tiezi> gettiezi(string xsn)
        {
            //链接数据库查询students表里的姓名里有｛xsn｝的所以数据，new｛xsn｝是要删改的一条数据
            MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString1"]);
            var list = mySqlConnection.Query<tiezi>($"SELECT * FROM tiezi WHERE tiezi_title like '%{xsn}%'", new { xsn }).ToList();
            return list;
        }
    }
}
